package com.wuren.faceSwiping.admin.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wuren.faceSwiping.admin.entity.User;
import com.wuren.faceSwiping.admin.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@SuppressWarnings("ALL")
@Service
public class UserService extends ServiceImpl<UserMapper, User> {
    @Autowired
    private UserMapper userMapper;

    public int userLogin(User user) {
        //定义一个查询条件
        QueryWrapper wrapper = new QueryWrapper();
        //判断是否输入用户名和密码
        if (user.getUsername() != null && user.getUsername().length() > 0 && user.getPassword() != null && user.getPassword().length() > 0) {
            //新增一个查询参数
            wrapper.eq("username",user.getUsername());
            wrapper.eq("password",user.getPassword());
            return userMapper.selectCount(wrapper);
        }
        return 0;
    }
}
